package com.chenfan.process.service;

import com.baomidou.mybatisplus.extension.service.IService;
import com.chenfan.process.entity.po.ProcessInstanceApprovePo;
import com.chenfan.process.entity.po.TemplateConfigPo;
import com.chenfan.process.enums.InstanceEnums;

import java.util.Collection;
import java.util.Collections;
import java.util.List;

/**
 * @author K
 * @date 2021-04-26
 */
public interface ProcessInstanceApproveService extends IService<ProcessInstanceApprovePo> {
    void updateApproval(Long approvalId, Integer status);

    void updateApproval(Long approvalId, Integer status, String remark);

    default void updateApprovalAlone(Long approvalId, Integer status, String remark) {
        updateApprovalAlone(approvalId, status, remark, null, null);
    }

    void updateApprovalAlone(Long approvalId, Integer status, String remark, Long userId, TemplateConfigPo config);

//    void updateApprovalAlone(Long approvalId, Integer status, String remark);

    void updateApproval(Long approvalId, Integer status, Long userId, String userName);

    List<ProcessInstanceApprovePo> getApproval(Long approvalId);

    List<ProcessInstanceApprovePo> getApprovalWithoutStatus(Long approvalId);

    ProcessInstanceApprovePo getByApprovalId(Long approvalId);

    List<ProcessInstanceApprovePo> getByDetailId(Long approvalId, Long detailId);

    List<ProcessInstanceApprovePo> getByDetailIdWithoutStatus(Long approvalId, Long detailId);

    List<ProcessInstanceApprovePo> getByDetailAndId(Long approvalId, Long detailId);

    List<ProcessInstanceApprovePo> listByDetailIdList(List<Long> detailIdList);

    List<ProcessInstanceApprovePo> listApprovingInstance(Long approvalTemplateId);

    default List<ProcessInstanceApprovePo> listApprovalInstance(Collection<Long> approvalIdList) {
        return listApprovingInstances(approvalIdList, null);
    }

    List<ProcessInstanceApprovePo> listApprovingInstances(Collection<Long> approvalIdList, Integer status);

    default List<ProcessInstanceApprovePo> listApprovingInstances(Collection<Long> approvalIdList) {
        return listApprovingInstances(approvalIdList, InstanceEnums.NORMAL.getCode());
    }

    List<ProcessInstanceApprovePo> listApprovingInstance(List<Long> approvalTemplateId);

    // 列出审批完的数据
    default List<ProcessInstanceApprovePo> listApprovedInstance(List<Long> approvalIdList) {
        return listApprovingInstances(approvalIdList, InstanceEnums.PASS.getCode());
    }

    default List<ProcessInstanceApprovePo> listApprovedInstance(Long approvalId) {
        return listApprovingInstances(Collections.singletonList(approvalId), InstanceEnums.PASS.getCode());
    }
}
